package edu.cuit.avatar.thread;

/**
 * 由于Thread类实现了Runnable接口，所以可以定义一个Thread的扩展类，并且覆盖run方法
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/16 9:55
 */
public class CustomThread extends Thread{
    private int ticket = 100;

    @Override
    public void run() {
        while(ticket > 0) {
            System.out.println(Thread.currentThread().getName() + "正在卖出编号为" + ticket + "的票");
            ticket--;
        }
    }

    public static void main(String[] args) {
        Thread thread = new CustomThread();
        thread.start();
    }
}
